<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <!-- width 控制布局视口的大小          设备    宽度-->
    <!-- <meta name="viewport" content="width=device-width" /> -->
    <!-- <meta name="viewport" content="width=2000" /> -->
    <!-- initial-scale  initial初始化  scale 比例 -->
    <meta name="viewport" content="initial-scale=1" />
    <!-- 两个同时控制 值大的那个生效-->
    <!-- <meta name="viewport" content="initial-scale=0.5, width=1000" />  -->
    <!-- 设置显示的最大视觉视口 -->
    <!-- <meta name="viewport" content="minimum-scale=1" />     -->
    <!-- <meta name="viewport" content="maximum-scale=1" />     -->
    <!-- <meta name="viewport" content="maximum-scale=1,minimum-scale=1" />     -->
    <!-- <meta name="viewport" content="user-scalable=no" />  -->


    <title>viewport</title>
    <style>
        #result {
            width: 200px;
            height: 200px;
            border: solid 1px #ddd;
        }
    </style>
</head>

<body>
    <div id="result"></div>
    <script>
        //潜规则, 在 JS 代码中可以直接使用与 id 同名的 变量
        setInterval(() => {
            result.innerHTML = (
                `当前布局视口的宽度: ${document.documentElement.clientWidth}<br>
                    当前视觉视口的宽度: ${window.visualViewport.width}
                `)
        }, 100)
    </script>
</body>

</html>

